package com.yami.shop.multishop.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.model.ShopWalletLog;
import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.security.multishop.util.SecurityUtils;
import com.yami.shop.service.ShopWalletLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;


/**
 * 商家钱包记录
 *
 * @author Dwl
 * @date 2019-09-19 14:02:57
 */
@RestController
@AllArgsConstructor
@RequestMapping("/shop/shopWalletLog")
@Tag(name = "商家钱包记录接口")
public class ShopWalletLogController {

    private final ShopWalletLogService shopWalletLogService;

    @GetMapping("/page")
    @Operation(summary =  "分页查询商家收入明细", description = "分页查询商家收入明细")
    public ServerResponseEntity<IPage<ShopWalletLog>> getShopWalletLogPage(PageParam<ShopWalletLog> page,@ParameterObject ShopWalletLog shopWalletLog){
        if (Objects.isNull(shopWalletLog.getShopId())){
            shopWalletLog.setShopId(SecurityUtils.getShopUser().getShopId());
        }
        IPage<ShopWalletLog> shopWalletLogPage = shopWalletLogService.pageByParam(page, shopWalletLog);
        return ServerResponseEntity.success(shopWalletLogPage);
    }
}
